#!/usr/bin/env python
# --*-- encoding:utf-8 --*-- 


from django.core.management.base import BaseCommand
from django.conf import settings
from fetion.webim import FetionWebIM
import SimpleXMLRPCServer
import logging

logger = logging.getLogger('fetion')


HOST_IP = "localhost"
HOST_PORT = settings.RPC_PORT

class Command(BaseCommand):
    
    def handle(self, *args, **options):
        
        server = SimpleXMLRPCServer.SimpleXMLRPCServer((HOST_IP, HOST_PORT),allow_none=True)
        server.register_instance(FetionWebIM(logger))
        print "Listening on port %s:%s"%(HOST_IP,HOST_PORT)
        server.serve_forever()